package org.biubiu0002.baiblog.core.controller;

import com.google.common.base.Preconditions;
import org.biubiu0002.baiblog.common.utils.R;
import org.biubiu0002.baiblog.core.annotations.PermissionIgnore;
import org.biubiu0002.baiblog.core.model.vo.UserInfoVo;
import org.biubiu0002.baiblog.core.model.vo.req.GroupUserInviteReqVo;
import org.biubiu0002.baiblog.core.service.GroupUserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: biubiu0002
 * @Date: 2022/12/8 14:25
 **/
@RestController
@RequestMapping("/groupUser")
public class GroupUserController {
    @Resource
    private GroupUserService groupUserService;

    @PostMapping("/invite")
    @PermissionIgnore
    public R inviteUser(@RequestBody GroupUserInviteReqVo groupUserInviteReqVo){
        List<String> uidList = groupUserInviteReqVo.getUidList();
        Preconditions.checkArgument(uidList.size()<=50,"一次最多邀请50人");
        groupUserService.inviteUser(groupUserInviteReqVo);
        return R.ok();
    }

    @GetMapping("/{uid}/groupUserInfo")
    public R getGroupUserInfo(@PathVariable("uid") String uid){
        List<UserInfoVo> userInfoVos = groupUserService.getGroupUserInfo(uid);
        return R.ok().put("data",userInfoVos);
    }

    @PostMapping("/kickOut")
    public R kickOutUser(){
        return R.ok();
    }

}
